/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tomica.object;

import tomica.utils.TomicaUtils;

/**
 *
 * @author Tung
 */
public class ATTRIBUTE_NOT_OBJECT {

    private long type;
    private byte[] pValueBytes;
    private long pValueLong;
    private boolean pValueBoolean;
    private byte pValueByte;
    private int typeData; 
//    private String pValueString;

    public ATTRIBUTE_NOT_OBJECT() {
    }

    public long getType() {
        return type;
    }

    public void setType(long type) {
        this.type = type;
    }

    public byte[] getpValueBytes() {
        return pValueBytes;
    }

    public void setpValueBytes(byte[] pValueBytes) {
        this.pValueBytes = pValueBytes;
    }

    public long getpValueLong() {
        return pValueLong;
    }

    public void setpValueLong(long pValueLong) {
        this.pValueLong = pValueLong;
    }

    public boolean ispValueBoolean() {
        return pValueBoolean;
    }

    public void setpValueBoolean(boolean pValueBoolean) {
        this.pValueBoolean = pValueBoolean;
    }

    public byte getpValueByte() {
        return pValueByte;
    }

    public void setpValueByte(byte pValueByte) {
        this.pValueByte = pValueByte;
    }

    public int getTypeData() {
        return typeData;
    }

    public void setTypeData(int typeData) {
        this.typeData = typeData;
    }

//    public String getpValueString() {
//        return pValueString;
//    }
//
//    public void setpValueString(String pValueString) {
//        this.pValueString = pValueString;
//    }
    
    
    
    
    public void setpValue(Object pValue) {
        typeData = 0;
        if (pValue instanceof byte[]) {
            typeData = 1;
            System.out.println("[ostt1_TokenLib-toCGetAttributes] pValue is byte[]");
            pValueBytes = (byte[]) pValue;
        } else if (pValue instanceof char[]) {
//            typeData = 5;
//            System.out.println("[ostt1_TokenLib-toCGetAttributes] pValue is char[]");
//            pValueString = new String( (char[]) pValue);
            typeData = 1;
            System.out.println("[ostt1_TokenLib-toCGetAttributes] pValue is char[]");
            pValueBytes = TomicaUtils.charsToBytes((char[]) pValue);
        } else if (pValue instanceof boolean[]) {
            System.out.println("[ostt1_TokenLib-toCGetAttributes] pValue is boolean[]");
        } else if (pValue instanceof int[]) {
            System.out.println("[ostt1_TokenLib-toCGetAttributes] pValue is int[]");
        } else if (pValue instanceof long[]) {
            System.out.println("[ostt1_TokenLib-toCGetAttributes] pValue is long[]");
        } else {
            // the other supported objecty types: Boolean, Long, Byte, ... are immutable, no clone needed
            //clone.pValue = this.pValue;
            if (pValue instanceof Long) {
                typeData = 2;
                System.out.println("[ostt1_TokenLib-toCGetAttributes] long type value: " + (Long) (pValue));
                pValueLong = (Long) (pValue);
            } else if (pValue instanceof Boolean) {
                typeData = 4;
                System.out.println("[ostt1_TokenLib-toCGetAttributes] boolean type value: " + (Boolean) (pValue));
                pValueBoolean = (Boolean) (pValue);
                if (pValueBoolean) {
                    pValueByte = 1;
                }
                else pValueByte = 0;
            } else if (pValue instanceof Byte) {
                typeData = 4;
                System.out.println("[ostt1_TokenLib-toCGetAttributes] byte type value: " + (Byte) (pValue));
                pValueByte = (Byte) (pValue);
            }
        }
    }
}
